using UnityEngine;
using System.Collections;

public class MothershipScript : MonoBehaviour {
	
	private Vector3 target_location;
	private float t = 0;
	

	// Use this for initialization
	void Start () {
		target_location = NewPoint();// + new Vector2(220,1620);
	}
	
	// Update is called once per frame
	void Update () {
		Vector3 v3 = Vector3.Lerp (transform.position, target_location, t);
		//Debug.Log ("target location: "+v3);
		transform.position = new Vector3(v3.x, v3.y, v3.z);
		t += Time.deltaTime;//1000;
		//Debug.Log ("t: "+t);
		if(t >= 1.01)
		{
			//Debug.Log ("NEW LOCATION");
			target_location = NewPoint();// + new Vector2(220, 1620);
			t=0;
		}
	}
	
	Vector3 NewPoint()
	{
		float r = 50;
		float x = Random.Range(-r, r);
		float y = Mathf.Sqrt((r*r)-(x*x));
		if((int)x%2 == 0)
		{
		//	Debug.Log ("y reversed");
			y = -y;
		}
		//Debug.Log ("target_location: "+"x: "+x+", y: "+y);
		return new UnityEngine.Vector3(x+220,15,y+1620);
	}
}
